import random
import sys
import time

while 1:
    print('+ + + + + + + + + + + + + + + + + + + +')
    print('|                                     |')
    print('|            -人生重开游戏-             |')
    print('|       1.开始游戏   2.退出游戏          |')
    print('|                                     |')
    print('+ + + + + + + + + + + + + + + + + + + +')
    i = int(input('请输入:>'))
    if i == 2:
        break
    while 1:
        print('请分配各项初始天赋值<总共20点> ')
        intelligence = int(input('请输入智力(1~10):> '))
        appearance = int(input('请输入颜值(1~10):> '))
        strength = int(input('请输入体质(1~10):> '))
        family = int(input('请输入家庭条件(1~10):>'))
        total = intelligence + appearance + strength + family
        if total > 20 or total < 0:
            print('请满足分配点数于0~20之间,重新分配')
            continue
        print(f"确定如下分配吗? 智力:{intelligence} 颜值:{appearance} 体质:{strength} 家庭:{family}")
        print('1.确认         2.重新分配')
        r = int(input('请输入:> '))
        if r == 2:
            continue
        break
    print('游戏开始!')
    random_num = random.randint(0, 1)
    if random_num:
        sex = 'male'
    else:
        sex = 'female'
    if sex == 'male':
        print('你是一个男孩')
    else:
        print('你是一个女孩')
    time.sleep(1)
    random_num = random.randint(1, 3)
    if 8 <= family <= 10:
        if random_num == 1:
            print('你出生在帝都,父母是高官政要')
            time.sleep(1)

            family += 1
            intelligence += 1
            appearance += 1
        if random_num == 2:
            print('你出生在一线城市,父亲是高薪白领,母亲是模特')
            time.sleep(1)

            strength -= 1
            family += 2
            appearance += 2
        if random_num == 3:
            print('你出生在一线城市,父亲是漫画家,母亲是芭蕾舞者')
            time.sleep(1)
            print('你遗传了来自你父亲的想象力和母亲的灵活性')
            time.sleep(1)
            intelligence += 2
            strength += 1
    elif 4 <= family <= 7:
        if random_num == 1:
            print('你出生在二线城市,父亲是篮球教练,母亲是瑜伽教练')
            time.sleep(1)
            print('他梦想着有一天你能替他完成他年轻时因伤未了的目标')
            strength += 3
            intelligence -= 2
        if random_num == 2:
            print('你出生在二线城市,家里开了一家小餐馆,父亲是厨师,母亲打理生意')
            intelligence += 2
            print('疫情时代,生意不太好做')
            time.sleep(1)

            family -= 1
        if random_num == 3:
            print('你出生在县上,父亲为了赚钱在省外工作,母亲是小公司职员')
            time.sleep(1)
            print('家境普通,日子勉强小康')
            time.sleep(1)
            family -= 1
            print('父母工作很忙,对你缺少管教,你打小不爱学习')
            print('你像港片里的古惑仔学习,并在学校混出了名堂')
            print('你早熟,处理事情心狠手辣,并且看人很准')
            strength += 1
            intelligence += 1
    elif 0 <= family <= 3:
        if random_num == 1:
            print('你出生在穷乡僻壤,父母合伙在工地搬砖')
            time.sleep(1)
            strength += 2
            family -= 3
        if random_num == 2:
            print('你被随意遗弃在小镇的街上,恰好被没有生育能力的热心夫妇捡到收养')
            time.sleep(1)

            appearance -= 1
        if random_num == 3:
            print('你出生在大学女厕所,你的出生是一场以外,你母亲把你冲进了下水道')
            time.sleep(1)
            print('游戏结束')
            time.sleep(1)

            continue
    # 幼年阶段
    age = 1
    flag = 0
    for e in range(1, 11):
        random_num = random.randint(1, 3)
        info = f"你今年{age}岁"
        if random_num == 1:
            # 身体引发
            if strength < 4:
                info += '你生病,'
                if family > 3:
                    info += '给你治病花了很多钱,但还是治好了'
                    strength += 2
                    family -= 2
                else:
                    info += '家里倾家荡产也治不好你的病,你夭折了'
                    flag = 1
            elif strength > 6 and age < 4:
                info += '你能一口气上爬两个楼梯'
            elif 4 < age < 8:
                info += '你能一口气跳上三个楼梯'
            # 家庭引发
            elif family < 4:
                if sex == 'female':
                    info += '家里重男轻女非常严重,你被抛弃了'
                    flag = 1
                else:
                    info += '家庭条件不太好,饿肚子'
                    strength -= 1
                    if strength <= 0:
                        info += '你被饿死了'
                        flag = 1
            elif family > 6:
                info += '父母给你新报了一家幼儿培训班'
                intelligence += 2
                family -= 1
            elif intelligence > 5:
                if age < 5:
                    info += ',你能算出自己有多少根手指头'
                else:
                    info += ',你能边跑边背九九乘法表'
            elif intelligence <= 5:
                info += '你还学不会唱歌'
            if family > 5:
                info += '专家每天给你按摩大脑头皮试图激发你的学习能力'
                intelligence+=1



        elif random_num == 2:
            if family < 3:
                info += '父亲中了彩票'
                family += 2
            elif appearance > 5 and age > 5:
                info += ',你越来越没有从前好看了'
                appearance -= 1
            elif appearance < 5:
                info += '你长得不好看,被周围的小朋友嫌弃'
                if family > 5:
                    info += '父母得知后帮你打扮'
                    family -= 1
                    appearance += 1
                else:
                    info += ',你被嘲笑,变得傻傻的'
                    intelligence -= 1
        elif random_num == 3:
            if family > 5:
                info += '经济形势不景气,家境不比从前'
                family -= 2
            elif family <= 5:
                info += '父亲炒股赚钱了'
                family += 2
            elif strength > 5:
                info += '你染上了流行病毒'
                if family > 5:
                    info += ',你还传染给了父母,导致它们无法工作'
                    family -= 1
                strength -= 1
            elif intelligence > 5:
                info += ',学习走路时,摔了一跤,磕到脑子,摔得没从前聪明了'
                intelligence -= 2
        if info == f"你今年{age}岁":
            info += '健康成长'
            if random_num == 1:
                info += '你更好看了'
                appearance += 1
            if random_num == 2:
                info += '你更聪明了'
                intelligence += 1
            if random_num == 3:
                info += '你更健康了'
                strength += 1
        print(info)
        time.sleep(1)
        print(f'智力:{intelligence} 颜值:{appearance} 体质:{strength} 家庭:{family}')
        time.sleep(1)
        print('---------------------------------------------------')
        age += 1
        time.sleep(1)
        if flag:
            break
    # 青年部分
    #...